﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Nathan_tools
{
    public partial class frm_links_generate : Form
    {
        public frm_links_generate()
        {
            InitializeComponent();
        }
        private void btn_openfolder_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == folderBrowserDialog1.ShowDialog())
            {
                DirectoryInfo dinfo =new DirectoryInfo (folderBrowserDialog1 .SelectedPath );
                foreach (FileInfo fi in dinfo.GetFiles())
                {
                    lb_files.Items.Add(fi.Name);
                }
            }
        }
        private void btn_openfile_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == openFileDialog1.ShowDialog())
            {
                foreach (string f in openFileDialog1.FileNames)
                {
                   string  fn = Path.GetFileName(f);
                    lb_files.Items.Add(fn);
                }
            }
        }

        private void btn_code_generate_Click(object sender, EventArgs e)
        {
            if (lb_files.Items.Count > 0)
            {
                for (int i=0; i < lb_files.Items.Count; i++)
                {
                    tb_linkcode.Text += "<a href='" + lb_files.Items[i].ToString() + "'>" + lb_files.Items[i].ToString() + "</a></br /></br />\r\n"; 
                }
            }
            Clipboard.SetText (tb_linkcode.Text);
        }



        private void btn_embmusic_Click(object sender, EventArgs e)
        {
            if (lb_files.Items.Count > 0)
            {
                for (int i = 0; i < lb_files.Items.Count; i++)
                {
                    tb_linkcode.Text += lb_files.Items[i].ToString()+ "<br><EMBED src='" + lb_files.Items[i].ToString()
                        + "'autostart='false' loop='false' hidden='false' width='"
                        + tb_player_width.Text + "' height='" 
                        + tb_player_high.Text + "'></br /></br />\r\n";
                }
            }
            Clipboard.SetText(tb_linkcode.Text);
        }

        private void tb_linkcode_TextChanged(object sender, EventArgs e)
        {

        }

        private void btn_clearfile_Click(object sender, EventArgs e)
        {
            lb_files.Items.Clear();
        }

        private void btn_codeclear_Click(object sender, EventArgs e)
        {
            tb_linkcode.Text = "";
        }
    }
}
